package com.joysuch.wwyt.bp.controller;

import com.joysuch.wwyt.bp.bean.investigate.BpInvestigateTypeBean;
import com.joysuch.wwyt.bp.entity.investigate.BpInvestigateType;
import com.joysuch.wwyt.bp.service.BpInvestigateTypeService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author ZhangDong
 * @Date 2020/3/25 16:49
 */
@RestController
@RequestMapping("/bp/investigate/type")
@Api(tags = "隐患管理-隐患排查计划-排查类型")
public class BpInvestigateTypeController {

    @Autowired
    private BpInvestigateTypeService bpInvestigateTypeService;

    @PostMapping("save")
    @RequiresPermissions("bp:investigate:type:save")
    @ApiOperation("新增/修改排查内容")
    public ResultBean save(@RequestBody @Valid BpInvestigateTypeBean bean) {
        return bpInvestigateTypeService.save(bean);
    }

    @GetMapping("/delete/{id}")
    @RequiresPermissions("bp:investigate:type:delete")
    @ApiOperation(value = "根据排查类型Id删除")
    @ApiImplicitParam(name = "id", value = "排查类型Id", paramType = "path", required = true)
    public ResultBean delete(@PathVariable Long id) {
        return bpInvestigateTypeService.delete(id);
    }

    @GetMapping("/page")
    @ApiOperation(value = "排查计划分页查询", response = BpInvestigateType.class)
    public ResultBean list(Pageable pageable) {
        return bpInvestigateTypeService.page(pageable);
    }

}
